home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / w3 / url-irc.el.z / url-irc.el
Encoding:
Text File  |  1998-05-21  |  2.7 KB  |  75 lines

  1. ;;; url-irc.el --- IRC URL interface
  2. ;; Author: wmperry
  3. ;; Created: 1997/10/17 14:08:02
  4. ;; Version: 1.7
  5. ;; Keywords: comm, data, processes
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;;; Copyright (c) 1996 by William M. Perry <wmperry@cs.indiana.edu>
  9. ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
  10. ;;;
  11. ;;; This file is not part of GNU Emacs, but the same permissions apply.
  12. ;;;
  13. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  14. ;;; it under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 2, or (at your option)
  16. ;;; any later version.
  17. ;;;
  18. ;;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
  25. ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26. ;;; Boston, MA 02111-1307, USA.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29. (require 'url-vars)
  30. (require 'url-parse)
  31.  
  32. (defcustom url-irc-function 'url-irc-zenirc
  33.   "*Function to actually open an IRC connection.
  34. Should be a function that takes several argument:
  35.     HOST - the hostname of the IRC server to contact
  36.     PORT - the port number of the IRC server to contact
  37.  CHANNEL - What channel on the server to visit right away (can be nil)
  38.     USER - What username to use
  39. PASSWORD - What password to use"
  40.   :type '(choice (const :tag "ZEN IRC" :value 'url-irc-zenirc)
  41.          (function :tag "Other"))
  42.   :group 'url)
  43.  
  44. (defun url-irc-zenirc (host port channel user password)
  45.   (let ((zenirc-buffer-name (if (and user host port)
  46.                 (format "%s@%s:%d" user host port)
  47.                   (format "%s:%d" host port)))
  48.     (zenirc-server-alist
  49.      (list
  50.       (list host port password nil user))))
  51.     (zenirc)
  52.     (goto-char (point-max))
  53.     (if (not channel)
  54.     nil
  55.       (insert "/join " channel)
  56.       (zenirc-send-line))))
  57.  
  58. (defun url-irc (url)
  59.   (let* ((urlobj (url-generic-parse-url url))
  60.      (host (url-host urlobj))
  61.      (port (string-to-int (url-port urlobj)))
  62.      (pass (url-password urlobj))
  63.      (user (url-user urlobj))
  64.      (chan (url-filename urlobj)))
  65.     (if (url-target urlobj)
  66.     (setq chan (concat chan "#" (url-target urlobj))))
  67.     (and (get-buffer url-working-buffer)
  68.      (kill-buffer url-working-buffer))
  69.     (if (string-match "^/" chan)
  70.     (setq chan (substring chan 1 nil)))
  71.     (if (= (length chan) 0)
  72.     (setq chan nil))
  73.     (funcall url-irc-function host port chan user pass)))
  74.     
  75.